package com.shd.edanpei.presenter;

import com.shd.edanpei.base.BasePresenterImpl;
import com.shd.edanpei.base.network.api.ApiCreator;
import com.shd.edanpei.base.network.rx.BaseObserver;
import com.shd.edanpei.base.network.rx.RxTransformer;
import com.shd.edanpei.util.contact.ContactBean;
import com.shd.edanpei.presenter.contract.UserDetailsContract;

import io.reactivex.android.schedulers.AndroidSchedulers;

/**
 * Created by mc on 2018/9/5.
 * yang-wen-wen
 */

public class UserDetailsPresenter extends BasePresenterImpl<UserDetailsContract.UserDetailsIView>
        implements UserDetailsContract.UserDetailsIPresenter {

    public UserDetailsPresenter(UserDetailsContract.UserDetailsIView mView) {
        super(mView);
    }

    @Override
    public void getDetails(long id) {
        ApiCreator.getApi().friendDetails(id)
                .compose(RxTransformer.<ContactBean>errorHandle())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new BaseObserver<ContactBean>() {
                    @Override
                    protected void onSuccess(ContactBean data) {
                        mBaseIView.setDetails(data);
                    }
                });
    }
}
